using System;
using System.Collections.Generic;
namespace MicroMsg.UI.Util
{
	public class SearchAlgorithm
	{
		private List<SearchItem> mListSItems;
		private Dictionary<string, List<SearchRetItem>> mDictHistoryRet;
		public SearchAlgorithm(List<SearchItem> listSItems)
		{
			this.mListSItems = listSItems;
		}
		public List<SearchRetItem> GetSearchRet(string strContent)
		{
			if (strContent == null)
			{
				return new List<SearchRetItem>();
			}
			strContent = strContent.ToLower();
			if (this.mDictHistoryRet == null)
			{
				this.mDictHistoryRet = new Dictionary<string, List<SearchRetItem>>();
			}
			else
			{
				if (this.mDictHistoryRet.ContainsKey(strContent))
				{
					return this.mDictHistoryRet.get_Item(strContent);
				}
			}
			List<SearchRetItem> list = new List<SearchRetItem>();
			if (this.mListSItems != null)
			{
				using (List<SearchItem>.Enumerator enumerator = this.mListSItems.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						SearchItem current = enumerator.get_Current();
						SearchMatchRange searchMatchRange = current.Match(strContent);
						if (searchMatchRange != null)
						{
							list.Add(new SearchRetItem(current.mSerachObj, searchMatchRange, current.mStrKey, current.mObjTag));
						}
					}
				}
			}
			if (list.get_Count() == 0)
			{
				return null;
			}
			this.mDictHistoryRet.set_Item(strContent, list);
			return list;
		}
	}
}
